<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="Author" content="Joseph Perl">
   <meta name="GENERATOR" content="Mozilla/4.76 [en] (Windows NT 5.0; U) [Netscape]">
   <title>HepRepXMLWriter</title>
</head>
<body>

<h1>
C++ Driver for HepRep XML</h1>
A C++ Driver Utility for HepRep XML files exists as a single pair of cc
and hh files:
<br><a href="http://www.slac.stanford.edu/~perl/heprepxml/HepRepXMLWriter.cc">&nbsp;&nbsp;
HepRepXMLWriter.cc</a>
<br><a href="http://www.slac.stanford.edu/~perl/heprepxml/HepRepXMLWriter.hh">&nbsp;&nbsp;
HepRepXMLWriter.hh</a>
<p>The HepRepXMLWriter helps you write <a href="http://heprep.freehep.org">HepRep</a>
xml files (HepRep version 1) suitable for viewing with the WIRED Event
Display.
<p>For details on the appropriate WIRED version, see the <a href="http://www.slac.stanford.edu/BFROOT/www/Computing/Graphics/Wired">SLAC
WIRED Home Page.</a>
<p>Examples of HepRep files can be found at:
<br><a href="http://www.slac.stanford.edu/~perl/heprepxml">&nbsp;&nbsp;
http://www.slac.stanford.edu/~perl/heprepxml</a>
<p>Two simple examples of main programs that uses HepRepXMLWriter are:
<br>&nbsp; <a href="http://www.slac.stanford.edu/~perl/heprepxml/HepRepXMLExample.cc">HepRepXMLExample.cc</a>
makes output: <a href="http://www.slac.stanford.edu/~perl/heprepxml/ExampleOutput.heprep">ExampleOutput.heprep</a>
<br>&nbsp; <a href="http://www.slac.stanford.edu/~perl/heprepxml/MakeSimpleBaBarHepRep.cc">MakeSimpleBaBarHepRep.cc</a>
makes output: <a href="http://www.slac.stanford.edu/~perl/heprepxml/SimpleBaBar.heprep">SimpleBaBar.heprep</a>
<p>The Geant4 Simulation program also contains a version of the HepRepXMLWriter
to allow complex detector simulations to be exported to HepRep.
<br>&nbsp; The tutorial <a href="http://www.slac.stanford.edu/BFROOT/www/Computing/Graphics/Wired/G4Tutorial.html">T01
produced for the February 2002 G4 Workshop at SLAC</a> makes output: <a href="http://www.slac.stanford.edu/~perl/heprepxml/G4ExamplesT01.heprep.gz">G4ExamplesT01.heprep.gz</a>
<br>&nbsp; The example in G4's /source/visualization/test/test19 makes
output: <a href="http://www.slac.stanford.edu/~perl/heprepxml/G4VisTest.heprep.gz">G4VisTest.heprep.gz</a>
<p>HepRepXMLWriter is easy to use.&nbsp; Its constructor takes no arguments.
<br>&nbsp;&nbsp; HepRepXMLWriter* hepRepXMLWriter = new HepRepXMLWriter();
<p>To open your file, call open with the appropriate file specification,
such as
<br>&nbsp;&nbsp; hepRepXMLWriter.open("MyFileName.heprep");
<p>Then create the various parts of the HepRep hierarchy by calls to
<br>&nbsp;&nbsp; hepRepXMLWriter.addType("someTypeName",hierarchy_depth)
<br>where the hierarchy depth determines what Types are considered subcomponents
of what other Types.
<p>Individual instances of a given Type, and their primitives are created
by calls to
<br>&nbsp;&nbsp; hepRepXMLWriter.addInstance()
<br>&nbsp;&nbsp; hepRepXMLWriter.addPrimitive()
<br>&nbsp;&nbsp; hepRepXMLWriter.addPoint(x,y,z)
<p>At any level in the hierarchy, you can add HepRep attributes with a
call such as:
<br>&nbsp;&nbsp; hepRepXMLWriter.addAttValue("LineWidth",2)
<p>The idea is that if there is an attribute value that should apply to
the entire picture, it is most efficient to set it once at the very top
of the hierarchy
<br>(so, for example, if you want all lines to be of width 2, make the
call before any addTypes, but if you then want one line to be a different
width, place another addAttValue call after the appropriate addType, addInstance
or addPrimitive).
<p>The complete set of pre-defined attributes is discussed at:
<br>&nbsp;&nbsp; http://heprep.freehep.org/heprep1/drawas.htm
<p>You can also define any new attributes.&nbsp; These will not affect
the drawing of the picture, but they will be available for viewing when
you pick on the relevant object and later features of WIRED will let you
perform cuts based on these attributes.&nbsp; See the <a href="http://heprep.freehep.org">HepRep</a>
documentation for details on the use of attributes.
<br>To define a new attribute, use the addAttDef method, as in:
<br>&nbsp;&nbsp; hepRepXMLWriter.addAttDef("Transverse Momentum", "PT",
"Physics", "GeV")
<p>The addAttValue method is overloaded so that you can provided attribute
values as any of char, bool, int or double.
<br>There is one extra form of addAttValue to allow you to provide colors
as separate r,g,b values (each value a double from 0 to 1).
<br>So for color red you could either do:
<br>&nbsp;&nbsp; addAttValue("LineColor","255,0,0")
<br>or
<br>&nbsp;&nbsp; addAttValue("LineColor",1.,0.,0.)
<p>Finally, make a call to close the file:
<br>&nbsp;&nbsp; hepRepXMLWriter.close()
<p>HepRepXMLWriter provides a few additional conveniences:
<ul>
<li>
There is never any need to call methods to end Points, Primitives, Instances
or Types (in fact you are not allowed to call these methods).&nbsp; HepRepXMLWriter
automatically inserts such things into the heprep file as needed.</li>

<li>
If you call addType twice for the same type name at the same depth level,
HepRepXMLWriter will suppress the extra addType, combining any Instances
of the second addType with those of the first addType.&nbsp; This means
you can freely call addType any time without worrying about whether you
have already done addType for this type name.</li>

<li>
Any time you open a new file, the previous file is automatically close
for you (no intervening call to close() is required).</li>

<li>
If you leave any levels out of the Type hierarchy (for example, you call
HepRepType with hieracrchy depth 0 and then call it with depth 2), the
missing depth levels are inserted automatically.</li>
</ul>
13 February 2002
<p><a href="http://www.slac.stanford.edu/~perl">Joseph Perl</a>
</body>
</html>
